package com.xujl.mvcbind.ui.list.control;

import android.os.Bundle;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.xujl.fastlib.base.BaseFragment;
import com.xujl.fastlib.base.BaseRvAdapter;
import com.xujl.mvcbind.adapter.ListAdapter;
import com.xujl.mvcbind.ui.list.model.GridListFragmentModel;
import com.xujl.mvcbind.ui.list.view.GridListFragmentView;

/**
 * <pre>
 *     author : xujl
 *     e-mail : 597355068@qq.com
 *     time   : 2019/08/20
 *     desc   : 网格list
 *     version: 1.0
 * </pre>
 */

public class GridListFragmentControl extends BaseFragment<GridListFragmentModel, GridListFragmentView> implements OnItemClickListener {
    private BaseRvAdapter mAdapter;

    public static GridListFragmentControl newInstance () {
        Bundle args = new Bundle();
        GridListFragmentControl fragment = new GridListFragmentControl();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected void init (Bundle savedInstanceState) {
        mAdapter = new ListAdapter(mModel.getBeanList());
        mView.setAdapter(mAdapter);
        mAdapter.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick (BaseQuickAdapter adapter, View view, int position) {
        mModel.setCheckedData(position);
        mAdapter.notifyDataSetChanged();
    }
}
